package com.hbnu.tonghengchang;

import java.util.Arrays;

public class Sort {
    public static void main(String[] args){
        String str = "53142";
        try {
            // 转换为字符数组
            char[] charArray = str.toCharArray();

            // 转换为数字数组
            int[] numberArray = new int[charArray.length];
            for (int i = 0; i < charArray.length; i++) {
                numberArray[i] = Character.getNumericValue(charArray[i]);
            }

            // 排序
            Arrays.sort(numberArray);

            // 输出结果
            System.out.println("原始字符串: " + str);
            System.out.println("字符数组: " + Arrays.toString(charArray));
            System.out.println("排序后数字数组: " + Arrays.toString(numberArray));
        }catch (Exception e){
            System.out.println("输入错误!!");
        }
    }
}
